Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JostinAlvaradoS/ticketing_project_week0/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Identity service manages user authentication and authorization. It handles user registration, password management, and JWT token issuance for accessing protected resources across the platform. Port: 50000 (external), 5000 (internal)Database Schema:
bc_identityDependencies: PostgreSQL
Responsibilities
- User registration and account creation
- Password hashing and verification
- JWT token generation and validation
- User credential management
- Serve as the authentication authority for all microservices
API Endpoints
Endpoints are defined using minimal API style.Issue Token (Login)
Authenticates a user and issues a JWT token for subsequent API requests.
User’s email address
User’s password
~/workspace/source/services/identity/src/Identity.Api/Program.cs
JWT access token
Token expiration timestamp (typically 2 hours from issuance)
Domain Models
User
Represents a user account in the system.Unique user identifier (auto-generated)
User’s email address (unique)
Hashed password (never stored in plain text)
~/workspace/source/services/identity/src/Identity.Domain/Entities/User.cs
Configuration
Database Connection
appsettings.json
JWT Configuration
- Key: Secret key for signing tokens (must be at least 32 characters)
- Issuer: Token issuer identifier
- Audience: Token audience (typically the service ecosystem)
- Expiry: Tokens expire 2 hours after issuance
Use Cases
IssueToken
Authenticates a user and issues a JWT token.~/workspace/source/services/identity/src/Identity.Application/UseCases/IssueToken/IssueTokenHandler.cs
CreateUser
Registers a new user account.~/workspace/source/services/identity/src/Identity.Application/UseCases/CreateUser/CreateUserHandler.cs
Ports (Interfaces)
The Identity service defines several domain ports:IUserRepository
Repository for user persistence.IPasswordHasher
Password hashing and verification.ITokenGenerator
JWT token generation.IDbInitializer
Database initialization and seeding.Database Initialization
On service startup, the Identity service:- Runs database migrations to create schema and tables
- Seeds a test user for development:
- Email:
test@example.com - Password:
Password123!
- Email:
Program.cs (startup)
JWT Token Structure
Generated JWT tokens include the following claims:- sub (subject): User ID (GUID)
- email: User’s email address
- iss (issuer):
SpecKit.Identity - aud (audience):
SpecKit.Services - exp (expiration): Timestamp (2 hours from issuance)
- iat (issued at): Timestamp
Authentication Flow
- User submits credentials: POST to
/tokenwith email and password - Validate user exists: Query database for user by email
- Verify password: Hash provided password and compare with stored hash
- Generate token: Create JWT with user claims and 2-hour expiry
- Return token: Send JWT and expiry timestamp to client
- Client stores token: Typically in localStorage or httpOnly cookie
- Subsequent requests: Client includes JWT in
Authorization: Bearer <token>header - Services validate token: Other services verify JWT signature and claims
Security Considerations
- Password Hashing: Passwords are hashed using BCrypt (or similar) before storage
- No plain-text passwords: Passwords are never stored or logged in plain text
- JWT expiration: Tokens expire after 2 hours to limit exposure window
- Secret key management: JWT signing key should be rotated regularly in production
- HTTPS: All authentication endpoints should be served over HTTPS in production
Architecture Notes
- Uses Minimal APIs for endpoint registration (no controllers)
- Uses Ports and Adapters pattern for infrastructure concerns
- Infrastructure services registered via
AddInfrastructure()extension method - Database initialization runs automatically on service startup
- Supports seeding test users for development environments
Integration with Other Services
Other microservices validate JWT tokens issued by the Identity service:- Extract JWT from
Authorizationheader - Verify signature using shared JWT secret key
- Validate issuer, audience, and expiration claims
- Extract user ID and email from token claims
- Proceed with authorized request
